package com.qjl.shopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qjl.shopping.bean.Account;
import com.qjl.shopping.bean.Admin;
import com.qjl.shopping.dao.AccountMapper;
import com.qjl.shopping.dao.AdminMapper;
import com.qjl.shopping.service.AccountService;
import com.qjl.shopping.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author liguanghui
 * @Date 2023/5/3
 */
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements AccountService {
    @Autowired
    private AccountMapper accountMapper;
    @Override
    public Page<Account> selectPage(int pageNum, int pageSize,int userId,int gameId) {
        Page<Account> page = new Page<>(pageNum,pageSize);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("account_id");
        if(userId!=0){
            queryWrapper.eq("account_user_id",userId);
        }
        if(gameId!=0){
            queryWrapper.eq("account_game_id",gameId);
        }
        Page<Account> accountPage = accountMapper.selectPage(page,queryWrapper);
        return accountPage;
    }
}
